package tiepbm.app.store.adapter;

import java.util.ArrayList;
import java.util.List;

import tiepbm.app.store.Global;
import tiepbm.app.store.activity.DetailActivity;
import tiepbm.app.store.activity.R;
import tiepbm.app.store.adapter.CategoryAdapter.ViewHolder;
import tiepbm.app.util.lazyLoader.ImageLoader_nghiank;
import tiepbm.app.util.lazyLoader.MyItem_img_nghiank;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.TextView;

public class HorizontalAdapter extends ArrayAdapter<String> {

	ArrayList<String> mItems = new ArrayList<String>()	;
	LayoutInflater mInflater;
	private Activity mContext;
	private MyItem_img_nghiank mItem_img3 = null;

	public HorizontalAdapter(Context mContext,ArrayList<String> mItems) {
		super(mContext,R.layout.test_item_1,mItems);
		mInflater = LayoutInflater.from(mContext);
		this.mContext =(Activity) mContext;
		this.mItems = mItems;
	}

	@Override
	public String getItem(int position) {
		// TODO Auto-generated method stub
		return mItems.get(position);
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mItems.size();
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View v = null;
		if (convertView == null) {
			LayoutInflater inflater = mContext.getLayoutInflater();
			v = inflater.inflate(R.layout.test_item_1, null);

			ViewHolder holder = new ViewHolder();

			holder.imvIcon = (ImageView) v.findViewById(R.id.image);
			v.setTag(holder);
		} else {
			v = convertView;
		}
		ViewHolder holder = (ViewHolder) v.getTag();
		mItem_img3 = new MyItem_img_nghiank(mContext, holder.imvIcon);
		try {
			ImageLoader_nghiank.getInstance().displayImage(mItems.get(position),
					mItem_img3);

		} catch (Exception e) {
		}
		return v;
	}
	static class ViewHolder{
		private ImageView imvIcon;
	}
}
